<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.easy.auth.domain.Action"%>
<%
	@SuppressWarnings("unchecked")
	List<Map<Action, List<Action>>> menuList = (List<Map<Action, List<Action>>>)session.getAttribute("menuList");
%>
<!-- 设置菜单链接样式 - begin -->
		<style>
			#firstLevelMenuDiv a:link {
			color:black;
			text-decoration:underline;
			}
			#firstLevelMenuDiv a:visited {
			color:black;
			text-decoration:none;
			}
			#firstLevelMenuDiv a:hover {
			color:white;
			text-decoration:none;
			}
			#firstLevelMenuDiv a:active {
			color:white;
			text-decoration:none;
			} 
			
			#accordionMenu a:link {
			color:black;
			text-decoration:underline;
			}
			#accordionMenu a:visited {
			color:black;
			text-decoration:none;
			}
			.easyui-menubutton a:hover {
			color:white;
			text-decoration:none;
			}
			#accordionMenu a:active {
			color:white;
			text-decoration:none;
			} 
		</style>
	<!-- 设置菜单链接样式 - end -->
<div data-options="region:'north',border:false"	style="font-family: Microsoft YaHei;">

	<%
	String username = session.getAttribute("userid") != null ? session
			.getAttribute("userid").toString() : "";
	String roleNames = session.getAttribute("roleNames") != null
			? session.getAttribute("roleNames").toString()
			: "";
	String firstMenuId = session.getAttribute("menuId") != null
			? session.getAttribute("menuId").toString()
			: "";
	String secondMenuId = session.getAttribute("secondMenuId") != null
			? session.getAttribute("secondMenuId").toString()
			: "";
	%>
	<div>
	 
	<div style="background: #27A9E3;width:100%;height:45px;" >
		<div style="height:45px;width: 265px;float: left;background-image: url(<%=request.getContextPath()%>/assets/img/head.png)">
			<img src="<%=request.getContextPath()%>/assets/img/logo.png" height="40px" width="50px"; style="margin-top:2px;"> 
			<span style="font-size: 16px;font-weight:bold; margin:8px 0px 0px 10px;position: absolute;">FCC匹配数据处理平台</span>
		</div>
	
	<div id="firstLevelMenuDiv" style="height:40px;width: 70%; float: left;">
		<%
		for(Map<Action, List<Action>> map : menuList){
			for(Action first : map.keySet()){
	%>
		<div style="width:120px;height:43px;float: left;text-align: center;">
			<%
				if(map.get(first)==null||map.get(first).size()==0){
			%>
				<div style="text-align: center;width:130px;height:33px;padding-top: 10px"	>
							<a href="#" onclick="javascript:openUrl('<%=first.getOid() %>','<%=first.getUrl() %>','<%=first.getOid() %>')" style="text-decoration: NONE;text-align:center;font-family:	Microsoft YaHei;">
							<span style="text-decoration: NONE;text-align:center;line-height: 24px;cursor:pointer;font-size: 14px;margin:3px 0px 0px 20px;color:#111111"><%=first.getOname() %></span>
						</a>
				</div>
		
			<%
				
				}else{
					if(firstMenuId.equals(first.getOid())){
			%>
			<div style="/* border-bottom:3px solid blue; */text-align: center;width:140px;height:33px;padding-top: 9px"
								onclick="javascript:changeMenu('<%=first.getOid() %>','<%=map.get(first).get(0).getUrl() %>','<%=map.get(first).get(0).getOid() %>')">
						<a href="javascript:void(0)" id="sysmb<%=first.getOid() %>" class="easyui-menubutton"
								data-options="menu:'#sysmm<%=first.getOid()%>',iconCls:'icon-menu'" >
							<span style="text-decoration: NONE;font-size: 14px;margin-top:2px;color:#111111"><%=first.getOname() %></span>
						</a>
						</div>
					<%
						}else{
					%>
						<div style="text-align: center;width:140px;height:33px;padding-top: 9px"
								onclick="javascript:changeMenu('<%=first.getOid() %>','<%=map.get(first).get(0).getUrl() %>','<%=map.get(first).get(0).getOid() %>')">
						<a href="javascript:void(0)" id="sysmb<%=first.getOid() %>" class="easyui-menubutton"
								data-options="menu:'#sysmm<%=first.getOid() %>',iconCls:'icon-menu'" >
							<span style="text-decoration: NONE;font-size: 14px;margin-top:2px;color:#111111"><%=first.getOname() %></span>
						</a>
						</div>
					<%
					}
				}
		
				%>
				


	</div>
			<div id="sysmm<%=first.getOid()%>" style="width: 120px;">
			<%
				List<Action> list = map.get(first);
			for(int i=0;i< list.size();i++){
			%>
			<div data-options="iconCls:'icon-filesave'" onclick="openUrl('<%=first.getOid()%>','<%=list.get(i).getUrl()%>','<%=list.get(i).getOid()%>')"><%=list.get(i).getOname() %></div>
				<!-- <div class="menu-sep"></div> -->
<%			
			}
%>
			</div>
		<%		
	}
			
	}
	%>
	
	</div>
	
	
	

	<div id="win" class="easyui-dialog" data-options="iconCls:'icon-help',modal:true"
				style="width: 360px; height: 200px; padding: 10px 10px" closed="true" 
				 closable="false"  >
				 请稍等。。。
			
	</div>
	<div style="float: right; width: 8%">
		<div style="height:35px;">
			<a href="javascript:void(0)" id="sysmb" class="easyui-menubutton"
				data-options="menu:'#sysmme',iconCls:'icon-man'" style="margin-top: 5px">
				<%=username%>
			</a>
			<div id="sysmme" style="width: 150px;">
				<div data-options="iconCls:'icon-undo'" onclick="logout()">注销</div>
				<!-- <div class="menu-sep"></div>
				<div data-options="iconCls:'icon-tip'" onclick="openHelpPanel()">说明</div>
				<div class="menu-sep"></div> -->
				<!-- <div data-options="iconCls:'icon-reload'">
					<span>主题切换</span>
					<div>
						<div onclick="changeThemeFun('default')">default</div>
						<div onclick="changeThemeFun('bootstrap')">bootstrap</div>
						<div onclick="changeThemeFun('metro')">metro</div>
						<div onclick="changeThemeFun('gray')">gray</div>
						<div onclick="changeThemeFun('black')">black</div>
						<div onclick="changeThemeFun('ui-sunny')">ui-sunny</div>
						<div onclick="changeThemeFun('ui-pepper-grinder')">ui-pepper-grinder</div>
						<div onclick="changeThemeFun('ui-dark-hive')">ui-dark-hive</div>
						<div onclick="changeThemeFun('ui-cupertino')">ui-cupertino</div>
						<div onclick="changeThemeFun('metro-red')">metro-red</div>
						<div onclick="changeThemeFun('metro-orange')">metro-orange</div>
						<div onclick="changeThemeFun('metro-green')">metro-green</div>
						<div onclick="changeThemeFun('metro-gray')">metro-gray</div>
						<div onclick="changeThemeFun('metro-blue')">metro-blue</div>
						<div onclick="changeThemeFun('icons')">icons</div>
						<div onclick="changeThemeFun('sunny')">sunny</div>
						<div onclick="changeThemeFun('darkhive')">darkhive</div> 
					</div>
				</div>-->
			</div>
		</div>
	</div>
	</div> 
	</div>
	<script type="text/javascript">
		$(function() {
			changeThemeFun('gray');
		});
	
		//注销
		function logout() {
			$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {
	            if (r) {
	            	var url = getRootPath() + '/LoginController/logout.do';
	        		window.location.href = url;
	            }
	        });
		}
		
		//打开说明窗口
		function openWait(){
			$('#win').dialog('open').dialog('setTitle', '系统提示');  // open a window  
		}
		function closeWait(){
			$('#win').dialog('close');
		}
		
		//打开对应管理模块
		function goToAction(url){
			window.location.href = getRootPath()+ url;
		}
	</script>
</div>

 

	
	
 
<div data-options="region:'south',border:false"
	style="height: 20px; background: #fff; padding: 5px;">
	<%@include file="/jsp/include/footer.jsp"%>
</div>
<script type="text/javascript">


function openUrl(oid,url,secondMenuId){
	//alert(url);
	if(url.indexOf('openFloder')>0||url.indexOf('loadAllNasReport')>0){
		doFunction(url);
		return;
	}
	//window.location.href = getRootPath() + url+"?secondMenuId="+soid;
	changeMenu(oid,url,secondMenuId);
}



<%-- <%=request.getContextPath()+list.get(i).getUrl()+"?secondMenuId="+list.get(i).getOid()%>

 --%>		//把点击选中的一级菜单的id保存到session中
		function changeMenu(oid,url,soid){
			$.ajax({
				type : 'post',
				async : false,
				url : getRootPath() + '/LoginController/putMenuIdInto.do',
				data : {"oid":oid,"soid":soid},
				success : function(result) {
					if(result.successful){
						window.location.href = getRootPath() + url+"?secondMenuId="+soid;
					}
				},
				dataType : 'json'
			}); 
		}
		function doFunction(url){
			if(url=='/ReportController/loadAllNasReport.do'){
				openWait();
			}
			$.ajax({
				type : 'post',
				url : getRootPath() + url,
				success: function(data){
					if(data.key=="openFolder"){
						ExeRun(data.value);
					}else if(data.key=="closeMessage"){
						 closeWait();
<%-- 						window.location.replace("<%=request.getContextPath() %>/ReportController/gotoDPV.do?secondMenuId=2"); --%>
					}
					
				},
				dataType : 'json'
			}); 
		}
		
		
		function showMessage(message){
			$.messager.show({
				title:'消息',
				msg:message,
				showType:'show',
				style:{
					right:'',
					top:'200px',
					bottom:''
				}
			});
		}
		
		function   ExeRun(command)  {
			
			  window.oldOnError=window.onerror;     
			  window._command=command;     
			  var   wsh;
			  window.onerror=function(err){     
				  if(err.indexOf('automation')!=-1){  
				  alert("命令"+window._command+"已经被用户禁止!");       
				            return   true;     
				  }     
				  else   return   false;     
			  }    
			  
			  try{ wsh=new   ActiveXObject("WScript.Shell");}catch(e){
				  alert("该功能需要使用IE浏览器，将本站加入到信任站点中，并开启 ‘对标记为可安全执行脚本的Activex控件执行脚本’功能");
				  //加入到信任站点，自定义级别，对标记为可安全执行脚本的Activex控件执行脚本
				  return;
			  }
			  if(wsh) { 
				  try{ 
					  
					   // wsh.Run("net use * /del /y "); 
					   $.messager.confirm('系统提示', '请先登录NAS，如果您已登录，请选择是', function(r) {
				            if (r) {
				            	  a= wsh.Run(command);
				            }
				        });
					  // var result={"title":"提示","msg":"您可以先登录nas，以免等待时间过长或无反应"};
					 //  $.messager.show(result);
					 
					 //a=wsh.Run('net use  \\\\10.135.33.40\\nas_fs   ')  ;
						//wsh.Run(command); 	
				  }catch(e){
					  //alert("1该功能需要使用IE浏览器，将本站加入到信任站点中，并开启 ‘对标记为可安全执行脚本的Activex控件执行脚本’功能");
					  //加入到信任站点，自定义级别，对标记为可安全执行脚本的Activex控件执行脚本
					  return;
				  }
			 
			  }  
			  window.onerror=window.oldOnError;     
			  
			  
			  
			  
	  }     
	</script>
	
	
	
	
	
	
	
	
	
	